<template>
    <view class="content">
        <view class="box u-m-t-30">
            <view class="item">
                <view>养护名称</view>
                <view class="item-r">{{data.name}}</view>
            </view>
            <view class="item">
                <view>养护品种数量</view>
                <view class="item-r">
                    <input type="number" v-model="num" placeholder="请输入" class="inp" :disabled="disabled">
                </view>
            </view>
            <view class="item">
                <view>养护合格批次</view>
                <view class="item-r">
                    <input type="number" v-model="batch" placeholder="请输入" class="inp" :disabled="disabled">
                </view>
            </view>
            <view class="item">
                <view>养护不合格批次</view>
                <view class="item-r">
                    <input type="number" v-model="unBatch" placeholder="请输入" class="inp" :disabled="disabled">
                </view>
            </view>
        </view>
        
        <view class="btn-square u-m-30" v-if="!data.status" @click="$noMultipleClicks(doSubmit)">确认</view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                noClick: true,//连点
                num: '',
                batch: '',
                unBatch: '',
                disabled: false,
                
                data: {},
            };
        },
        onLoad(option) {
            if (option.data) {
                this.data = JSON.parse(decodeURIComponent(option.data));
                
                if (this.data.status == 1) {
                    uni.setNavigationBarTitle({
                    	title:'养护分析报告'
                    })
                    this.disabled = true
                    this.num = this.data.category_nums
                    this.batch = this.data.pass_nums
                    this.unBatch = this.data.below_grade_nums
                }
            }
            
        },
        methods: {
            doSubmit() {
                if (!this.num || this.num <= 0) {
                    this.$toast('品种数量不能为空或小于0')
                    return
                }
                if (!this.batch || this.batch < 0) {
                    this.$toast('合格批次不能为空或负数')
                    return
                }
                if (!this.unBatch || this.unBatch < 0) {
                    this.$toast('不合格批次不能为空或负数')
                    return
                }
                this.$ajax('inventorys/add_analysis', {
                    userToken: this.$getSync('userToken'),
                    id: this.data.id,
                    category_nums: this.num,
                    pass_nums: this.batch,
                    below_grade_nums: this.unBatch,
                }).then(ret => {
                	if (ret.status == 0) {
                        this.$toast('提交成功')
                        setTimeout(() => {
                            this.$backT()
                        }, 500)
                	} else {
                		this.$toast(ret.message);
                	}
                });
            },
            
        }
    };
</script>

<style lang="scss">
    
    page{
        background-color: #f5f5f5 !important;
    }
    .title{
        font-weight: bold;
        padding: 45rpx 50rpx 25rpx;
        position: relative;
    }
    .title::after{
        display: block;
        content: '';
        width: 8rpx;
        height: 26rpx;
        background-color: #ff4800;
        position: absolute;
        left: 25rpx;
        bottom: 32rpx;
    }
    
    
    .box{
        padding: 0 20rpx;
        background-color: #fff;
        border-radius: 15rpx;
        margin: 0 30rpx;
    }
    .item{
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 30rpx 0;
        border-bottom: 2rpx solid #e6e6e6;
    }
    .item:last-child{
        border-bottom: none;
    }
    .item-r{
        flex: 1;
        word-break: break-all;
        white-space: pre-line;
        text-align: right;
        padding-left: 20rpx;
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }
    .inp{
        flex: 1;
    }
    .item-img{
        padding: 30rpx 0;
    }
    .img{
        width: 316rpx;
        height: 200rpx;
        border-radius: 10rpx;
        margin-top: 20rpx;
    }
    
    
    .drug{
        background-color: #fff;
        border-radius: 15rpx;
        padding: 35rpx 30rpx;
        margin-bottom: 25rpx;
        word-break: break-all;
        white-space: pre-line;
    }
    .drug:last-child{
        margin-bottom: 0;
    }
    .drug-state1{
        font-size: 24rpx;
        color: #0075ff;
        padding: 9rpx 12rpx;
        background-color: #ebf4fe;
        border-radius: 8rpx;
        margin-left: 20rpx;
    }
    
    
    .examine{
        word-break: break-all;
        white-space: pre-line;
        padding: 15rpx 25rpx 30rpx;
        background-color: #fff;
        border-radius: 15rpx;
        margin: 0 30rpx 25rpx;
    }
    .t-inp{
        width: 100%;
        min-height: 150rpx;
        height: auto;
        padding-top: 15rpx;
    }
    .examine2{
        padding: 15rpx 0;
    }
    .img-box{
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
    }
    .up-photo{
        width: 187rpx;
        height: 187rpx;
        margin-right: 15rpx;
        margin-top: 15rpx;
    }
    
    
    .btns{
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin: 30rpx;
    }
    .refuse-btn{
        font-size: 34rpx;
        color: #757575;
        padding: 25rpx 130rpx;
        background-color: #fff;
        border: 2rpx solid #d8d8d8;
        border-radius: 10rpx;
    }
    .take-btn{
        font-size: 34rpx;
        color: #fff;
        padding: 25rpx 130rpx;
        background-color: #ff4800;
        border-radius: 10rpx;
        margin-left: 20rpx;
    }
    
    .enter-btn{
        display: flex;
        justify-content: flex-end;
        align-items: center;
        padding-top: 10rpx;
    }
    .enter-btn>view{
        padding: 15rpx 50rpx;
        background-color: #8392a5;
        border-radius: 10rpx;
        color: #fff;
    }
    
    .place{
        word-break: break-all;
        white-space: pre-line;
        padding: 5rpx 20rpx 20rpx;
        background-color: #f5f6f8;
        border-radius: 10rpx;
        margin-top: 30rpx;
    }
    .wrapper{
        padding: 0 30rpx;
    }
    .choose-01{
        width: 33rpx;
        height: 33rpx;
        margin-right: 15rpx;
    }
    .time-02{
        width: 33rpx;
        height: 34rpx;
        margin-left: 15rpx;
    }

</style>
